function createURL()
{
    var name = prompt("Введите имя фильтра", "Имя");
    if (name == null){
        return false;
    }

    var length = document.URL.split("/").length;
    var controller_type = document.URL.split("/")[length-2];

    var per_page = document.page_select_form.per_page.value;

    var form = document.getElementById("filters");

    var filterURL="";
    var fieldcount = document.forms.filters.elements.length;
    var i;

    for(i = 0; i < fieldcount-1; i++) {  // fieldcount-1 because submit button also in form
        if (i != 0) {
            filterURL = filterURL + "&";
        }
        filterURL = filterURL + "column=" + form.elements[i].id;
        filterURL = filterURL + "&flt_" + form.elements[i].id + "=" +  form.elements[i].value;
    }
    window.location.replace("save_filter?name=" + name + "&controller_type=" + controller_type + "&" + filterURL +
                            "&per_page=" + per_page);
    return false;
}

function focusFirstField() {
    try {
        document.forms[0].elements[0].focus();
    } catch(e) {}
}
